Skip to content

fix: field usage when arguments have the same name as root fields#2440

Merged
JivusAyrus merged 4 commits intomainfrom
suvij/eng-8393-field-usage-confusion-for-queryholiday
Jan 7, 2026
Merged

fix: field usage when arguments have the same name as root fields#2440
JivusAyrus merged 4 commits intomainfrom
suvij/eng-8393-field-usage-confusion-for-queryholiday

Conversation

@JivusAyrus
Copy link
Copy Markdown
Member

@JivusAyrus JivusAyrus commented Jan 5, 2026

Summary by CodeRabbit

  • New Features
    • Field usage analytics now support filtering and tracking by argument vs. input types for more granular schema insights.
    • UI updates let you view input-specific field usage from schema explorer and field-usage sheets.
    • Analytics backend and queries now honor these new filters so reports and visualizations reflect argument/input context.

✏️ Tip: You can customize this high-level summary in your review settings.

Checklist

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 5, 2026

Walkthrough

Two boolean flags, is_argument and is_input, were added to GetFieldUsageRequest across the protobuf, generated TypeScript, backend service and repository layers, and frontend query UI to enable filtering field-usage by argument vs input context.

Changes

Cohort / File(s) Summary
Protobuf Definition
proto/wg/cosmo/platform/v1/platform.proto
Added is_argument (field 9) and is_input (field 10) to GetFieldUsageRequest.
Generated Protobuf TypeScript
connect/src/wg/cosmo/platform/v1/platform_pb.ts
Added isArgument and isInput properties with default false; updated fields list with scalar BOOL entries (nos. 9,10).
Backend Service
controlplane/src/core/bufservices/analytics/getFieldUsage.ts
Propagates optional isArgument and isInput flags into repository call (coerced to boolean defaults).
Repository / Data Access
controlplane/src/core/repositories/analytics/UsageRepository.ts
Added isArgument/isInput to method signature and query parameters; incorporated into SQL WHERE clause and shared params for downstream queries.
Frontend Components / Pages
studio/src/components/analytics/field-usage.tsx, studio/src/pages/.../schema/index.tsx
Derives isInput from route/context and passes it to getFieldUsage; minor JSX reformatting and conditional rendering adjustments.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: field usage when arguments have the same name as root fields' clearly and specifically describes the main issue being addressed in the changeset.
✨ Finishing touches
  • 📝 Generate docstrings

📜 Recent review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2becc65 and f992f09.

📒 Files selected for processing (1)
  • controlplane/src/core/repositories/analytics/UsageRepository.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • controlplane/src/core/repositories/analytics/UsageRepository.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: build-router
  • GitHub Check: image_scan (nonroot)
  • GitHub Check: integration_test (./events)
  • GitHub Check: build_test
  • GitHub Check: image_scan
  • GitHub Check: integration_test (./telemetry)
  • GitHub Check: build_push_image (nonroot)
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: build_push_image
  • GitHub Check: build_test
  • GitHub Check: build_test
  • GitHub Check: build_push_image
  • GitHub Check: build_push_image
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 5, 2026

Codecov Report

❌ Patch coverage is 0% with 54 lines in your changes missing coverage. Please review.
✅ Project coverage is 36.24%. Comparing base (f8cedae) to head (b56a5d4).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
[...ionSlug]/[namespace]/graph/[slug]/schema/index.tsx](https://app.codecov.io/gh/wundergraph/cosmo/pull/2440?src=pr&el=tree&filepath=studio%2Fsrc%2Fpages%2F%5BorganizationSlug%5D%2F%5Bnamespace%5D%2Fgraph%2F%5Bslug%5D%2Fschema%2Findex.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wundergraph#diff-c3R1ZGlvL3NyYy9wYWdlcy9bb3JnYW5pemF0aW9uU2x1Z10vW25hbWVzcGFjZV0vZ3JhcGgvW3NsdWddL3NjaGVtYS9pbmRleC50c3g=) 0.00% 45 Missing ⚠️
...src/core/repositories/analytics/UsageRepository.ts 0.00% 4 Missing ⚠️
studio/src/components/analytics/field-usage.tsx 0.00% 3 Missing ⚠️
...ne/src/core/bufservices/analytics/getFieldUsage.ts 0.00% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #2440       +/-   ##
===========================================
+ Coverage   29.01%   36.24%    +7.23%     
===========================================
  Files         127      944      +817     
  Lines       11047   123180   +112133     
  Branches      251     4927     +4676     
===========================================
+ Hits         3205    44644    +41439     
- Misses       7838    76993    +69155     
- Partials        4     1543     +1539     
Files with missing lines Coverage Δ
...ne/src/core/bufservices/analytics/getFieldUsage.ts 2.77% <0.00%> (ø)
studio/src/components/analytics/field-usage.tsx 0.00% <0.00%> (ø)
...src/core/repositories/analytics/UsageRepository.ts 51.51% <0.00%> (ø)
[...ionSlug]/[namespace]/graph/[slug]/schema/index.tsx](https://app.codecov.io/gh/wundergraph/cosmo/pull/2440?src=pr&el=tree&filepath=studio%2Fsrc%2Fpages%2F%5BorganizationSlug%5D%2F%5Bnamespace%5D%2Fgraph%2F%5Bslug%5D%2Fschema%2Findex.tsx&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=wundergraph#diff-c3R1ZGlvL3NyYy9wYWdlcy9bb3JnYW5pemF0aW9uU2x1Z10vW25hbWVzcGFjZV0vZ3JhcGgvW3NsdWddL3NjaGVtYS9pbmRleC50c3g=) 0.00% <0.00%> (ø)

... and 814 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jan 5, 2026

Router-nonroot image scan passed

✅ No security vulnerabilities found in image:

ghcr.io/wundergraph/cosmo/router:sha-ea0305c20e4b2aef40d852190ec0a3b4a20dcf5d-nonroot

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
proto/wg/cosmo/platform/v1/platform.proto (1)

2068-2069: Consider adding documentation for the new fields.

The new is_argument and is_input boolean fields are correctly defined and properly numbered. However, adding documentation comments would improve maintainability and help future developers understand their purpose.

💡 Suggested documentation
  optional string feature_flag_name = 8;
+  // is_argument filters field usage to only argument contexts
  bool is_argument = 9;
+  // is_input filters field usage to only input type contexts
  bool is_input = 10;
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 98bb8e9 and 2becc65.

⛔ Files ignored due to path filters (1)
  • connect-go/gen/proto/wg/cosmo/platform/v1/platform.pb.go is excluded by !**/*.pb.go, !**/gen/**
📒 Files selected for processing (6)
  • connect/src/wg/cosmo/platform/v1/platform_pb.ts
  • controlplane/src/core/bufservices/analytics/getFieldUsage.ts
  • controlplane/src/core/repositories/analytics/UsageRepository.ts
  • proto/wg/cosmo/platform/v1/platform.proto
  • studio/src/components/analytics/field-usage.tsx
  • studio/src/pages/[organizationSlug]/[namespace]/graph/[slug]/schema/index.tsx
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-08T20:57:07.946Z
Learnt from: JivusAyrus
Repo: wundergraph/cosmo PR: 2156
File: controlplane/src/core/repositories/SubgraphRepository.ts:1746-1763
Timestamp: 2025-09-08T20:57:07.946Z
Learning: The checkSubgraphSchema.ts file already correctly implements linked subgraph functionality, using byName(linkedSubgraph.name, linkedSubgraph.namespace) to fetch target subgraphs and properly handles parse(newSchemaSDL) for schema building. The implementation doesn't need fixes for byId usage or schema parsing as it's already correct.

Applied to files:

  • studio/src/pages/[organizationSlug]/[namespace]/graph/[slug]/schema/index.tsx
🧬 Code graph analysis (1)
studio/src/pages/[organizationSlug]/[namespace]/graph/[slug]/schema/index.tsx (2)
studio/src/lib/schema-helpers.ts (4)
  • getCategoryForType (330-374)
  • getTypeCounts (376-404)
  • getDeprecatedTypes (756-775)
  • getAuthenticatedTypes (777-801)
studio/src/hooks/use-workspace.ts (1)
  • useWorkspace (4-11)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (15)
  • GitHub Check: build-router
  • GitHub Check: build_push_image
  • GitHub Check: build_test
  • GitHub Check: build_test
  • GitHub Check: build_push_image
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: integration_test (./telemetry)
  • GitHub Check: Analyze (go)
  • GitHub Check: build_push_image
  • GitHub Check: build_push_image (nonroot)
  • GitHub Check: integration_test (./. ./fuzzquery ./lifecycle ./modules)
  • GitHub Check: build_test
  • GitHub Check: image_scan (nonroot)
  • GitHub Check: image_scan
  • GitHub Check: integration_test (./events)
🔇 Additional comments (8)
studio/src/components/analytics/field-usage.tsx (2)

359-361: LGTM! Clean category extraction and isInput derivation.

The logic correctly derives isInput from the router query parameter. When category is undefined or not "inputs", isInput defaults to false, which is the correct behavior for this field usage query.


376-376: LGTM! Correct integration with the backend.

The isInput flag is properly passed to the getFieldUsage query, enabling the backend to filter field usage by input context as intended.

connect/src/wg/cosmo/platform/v1/platform_pb.ts (2)

16035-16043: LGTM!

The new boolean properties follow the correct protobuf-es generated code patterns with appropriate default values (false for proto3 booleans) and proper camelCase naming convention.


16061-16062: LGTM!

The field definitions are correctly structured with sequential field numbers (9, 10) that don't conflict with existing fields, and properly use ScalarType.BOOL (T: 8) for boolean types.

controlplane/src/core/bufservices/analytics/getFieldUsage.ts (1)

79-80: LGTM!

Clean parameter passthrough with sensible defaults. The nullish coalescing ensures backward compatibility for callers that don't provide these new flags.

controlplane/src/core/repositories/analytics/UsageRepository.ts (2)

150-160: LGTM!

The method signature correctly requires explicit boolean values for isArgument and isInput, which aligns with the call site providing defaults. This ensures deterministic query behavior.


182-188: No changes needed. The ClickHouse schema correctly includes the IsArgument and IsInput columns (bool type) in the base table and materialized views, and the ingestion pipeline (graphqlmetrics/core/metrics_service.go) properly populates these fields. The parameterized SQL queries in UsageRepository.ts are safe and correctly target existing schema columns.

studio/src/pages/[organizationSlug]/[namespace]/graph/[slug]/schema/index.tsx (1)

197-215: LGTM! The isInput derivation is correct.

The logic correctly identifies input types by checking category === "inputs" and passes the flag to filter field usage appropriately.

Note: isArgument is not passed here, so it defaults to false at the backend. This means this view will only show non-argument field usage, which appears to be the intended behavior based on the PR objective of distinguishing arguments from root fields.

Copy link
Copy Markdown
Contributor

@wilsonrivera wilsonrivera left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@StarpTech StarpTech left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@JivusAyrus JivusAyrus merged commit 2b77baf into main Jan 7, 2026
44 checks passed
@JivusAyrus JivusAyrus deleted the suvij/eng-8393-field-usage-confusion-for-queryholiday branch January 7, 2026 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants